<!DOCTYPE html>
<html class="x-admin-sm">

<head>
  {include file="public/head"}
</head>

<body>
  {include file="public/breadcrumb"}
  <div class="x-body">
    <xblock>
      <button class="layui-btn" onclick="x_admin_show('添加管理员','/admin.php/Admin/add')">
        <i class="layui-icon"></i>添加
      </button>
      <span class="x-right" style="line-height:32px">共有&nbsp;<span style="color: #FF5722;font-weight: bold;">{$data.lists|count}</span>&nbsp;条数据</span>
    </xblock>
    <table class="layui-table">
      <thead>
        <tr>
          <th width="50">ID</th>
          <th>用户名</th>
          <th>真实姓名</th>
          <th>角色</th>
          <th>状态</th>
          <th>加入时间</th>
          <th width="150">操作</th>
      </thead>
      <tbody>
        {volist name="data.lists" id="vo"}
        <tr>
          <td>{$vo.id}</td>
          <td>{$vo.username}</td>
          <td>{$vo.truename}</td>
          <td>{:isset($data['groups'][$vo.gid])?$data['groups'][$vo.gid]['title']:''}</td>
          <td>{$vo.status==0?'正常':'<span style="color: red;">禁用</span>'}</td>
          <td>{:date('Y-m-d H:i:s',$vo.add_time)}</td>
          <td>
            <button class="layui-btn layui-btn-warm layui-btn-xs" onclick="x_admin_show('编辑管理员','/admin.php/Admin/add?id='+{$vo.id})">编辑</button>
            <button class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$vo.id})">删除</button>
          </td>
        </tr>
        {/volist}
      </tbody>
    </table>
  </div>
  <script>
    layui.use(['layer'],function(){
			layer = layui.layer;
			$ = layui.jquery;
		});

    // 删除
		function del(id){
			layer.confirm('确定要删除吗？', {
        icon:3,
			  btn: ['确定','取消']
			}, function(){
			  $.post('/admin.php/Admin/delete',{'id':id},function(res){
			  	if(res.code>0){
			  		layer.alert(res.msg,{icon:2});
			  	}else{
			  		layer.msg(res.msg);
			  		setTimeout(function(){window.location.reload();},1000);
			  	}
			  },'json');
			});
		}
  </script>
</body>

</html>